package cn.itcast.core.controller;

import cn.itcast.core.pojo.Dept;
import cn.itcast.core.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @auther :hyh
 * @desc :
 * @date :2019/5/8
 */
@RestController
public class DeptControllerConsumer {

    @Autowired
    private DeptClientService deptClientService;

    @GetMapping("/consumer/dept/list")
    public List<Dept> list() {
        List<Dept> list = deptClientService.list();
        return list;
    }

    @PostMapping("/consumer/dept/add")
    public  boolean  add(@RequestBody Dept dept) {
        Boolean aBoolean = deptClientService.add(dept);
        return aBoolean;
    }

    @GetMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") int id) {
        Dept obj = deptClientService.get((long) id);
        return obj;
    }

}
